#pragma once

#include <vector>

#include "Globals.h"
#include "Tile.h"

namespace game_engine { namespace tile_engine
{

/*!
 * \class TileWorld
 * \brief 
 */
class TileWorld
{
///////////////////////////////////////////////////////////////////////////////
// Attribute definition
///////////////////////////////////////////////////////////////////////////////
private:
  	Tile*** tiles;
    // In tiles
	INT32 worldWidth;
    // In tiles
    INT32 worldHeight;
    INT32 tileWidth;
    INT32 tileHeight;

///////////////////////////////////////////////////////////////////////////////
// Method definition
///////////////////////////////////////////////////////////////////////////////
public:
    // Constructors and Destructors
    TileWorld(void);
    virtual ~TileWorld(void);

    // Others
    void loadLevel(const string &levelFilename, const string &imageFilename) 
        throw(...);
    void draw(const utils::Point &cameraPosition, const utils::Rect &view) const;
    const Tile* tileAt(const utils::Point &worldPosition) const;
    //const BOOL walkable(const utils::Point &position) const;
    const vector<Tile*> surroundingTiles(const utils::Point &worldPosition) const;

    // Getters
    const INT32 getWorldWidth(void) const;
    const INT32 getWorldHeight(void) const;
	const INT32 getTileWidth(void) const;
	const INT32 getTileHeight(void) const;

    // Setters
    void setWorldWidth(const INT32 width);
    void setWorldHeight(const INT32 height);

private:
    void allocateTiles(void);
    void addTile(const INT32 idTile, const INT32 phys, const INT32 x, 
        const INT32 y, const string &imageFilename);
    void computeCoordinates(const utils::Point &worldPosition, INT32 &x, INT32 &y) 
        const throw (...);
    const BOOL tileExists(const INT32 x, const INT32 y) const;

};

}}
